Skip to content

Fix opcache.huge_code_pages #19388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arnaud-lb
Copy link
Member

@arnaud-lb arnaud-lb commented Aug 6, 2025

Building opcache into the main executable breaks opcache.huge_code_pages, as we were relying on the fact that accel_remap_huge_pages() is not in the same mapping as the main text segment.

Here I ensure that accel_remap_huge_pages() is placed out of the text segment, and remap only the text segment. This approach is used in https://github.com/intel/iodlr/blob/676bb7dec378d561e4d900fbdaed6ce8dbe449a1/large_page-c/large_page.c#L260.

This should work on the same systems supported by the original opcache.huge_code_pages implementation (Linux and FreeBSD).

I've also tried using mremap() in #19379, but it's not supported on FreeBSD. We could still use the mremap() approach on Linux.

Windows failure unrelated.

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understood your changes in accel_remap_huge_pages(). They are fine.

I didn't completely understand the reason of changes in accel_find_program_section().
What is the problem with the original version?
I don't care a lot, I just like to know.

@arnaud-lb
Copy link
Member Author

I made this change because /proc/self/maps reflects program segments, not sections. Each segment may contain multiple sections. The segment / memory mapping containing the .text section may also contains .plt, .init, .fini, as well as the section where I placed accel_remap_huge_pages (.remap_stub), and other unspecified sections.

accel_find_program_section() finds the exact start/end of the .text section only.

@dstogov
Copy link
Member

dstogov commented Aug 18, 2025

accel_find_program_section() finds the exact start/end of the .text section only.

OK.
Will it miss read-only data section? I'm not sure how it's represented in Elf. Original version remapped it to huge-pages together with .text out of the box.

@dstogov
Copy link
Member

dstogov commented Aug 18, 2025

I understood why you need this :) - to exclude .remap_stub.

@arnaud-lb
Copy link
Member Author

I understood why you need this :) - to exclude .remap_stub.

Yes :) This also avoids problems when accel_remap_huge_pages() calls code from other sections, such as .plt.

accel_find_program_section() finds the exact start/end of the .text section only.

OK. Will it miss read-only data section? I'm not sure how it's represented in Elf. Original version remapped it to huge-pages together with .text out of the box.

Oh, I didn't notice that. I will check if I can also remap the ro data section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants